{% extends 'iframe/basePlus.html.twig' %}
{% block cardHeader %}
    列表<a href="javascript:void(0);" class="layui-btn layui-btn-sm dry-right layui-btn-green cardRightTop" lay-event='gAdd'>添加</a>
{% endblock %}
{% block cardBody %}
    <script type="text/html" id="toolbar">
        <div class="layui-btn-container">
            <button class="layui-btn layui-btn-sm layui-btn-danger" lay-event="gDelete">批量删除</button>
            <button class="layui-btn layui-btn-sm" lay-event="gOperate">高级操作</button>
        </div>
    </script>
    <script type="text/html" id="bar">
        <a class="layui-btn layui-btn-xs" lay-event="show">查看</a>
        <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
        <a class="layui-btn layui-btn-xs layui-btn-danger" lay-event="delete">删除</a>
    </script>
    <table class="layui-hide" id="list" lay-filter="list"></table>
    <script>
        function getIndexColumn()
        {
            var list = [
                {
                    type: 'checkbox'
                },
                {
                    title: 'ID',
                    field: 'id',
                    width: ID_WIDTH
                },
                {
                    title: '名称',
                    field: 'dry_name',
                    width: WIDTH_250
                },
                {
                    title: '类型',
                    field: 'dry_type'
                },
                {
                    title: '范围开始',
                    field: 'dry_start'
                },
                {
                    title: '范围结束',
                    field: 'dry_end',
                    width: WIDTH_200
                },
                {
                    title: '备注',
                    field: 'dry_note',
                    edit: 'text'
                },
                {
                    title: '排序',
                    field: 'dry_sort',
                    width: SORT_WIDTH
                },
                {
                    title: '状态',
                    field: 'dry_status',
                    width: STATUS_WIDTH,
                    templet: function(rs){return mergeRequest("tag", "dry_status", rs.dry_status, "/Api/Choice/getListByKey?key=status", "", 1);}
                },
                {
                    title: '添加时间',
                    field: 'dry_add_time',
                    width: ADD_TIME_WIDTH
                },
                {
                    title:'操作',
                    toolbar: '#bar',
                    width: OPERATE_WIDTH
                }
            ];
            return list;
        }

        layui.use(['dry'], function(dry){
            var f = {};

            f.gAdd = function()
            {
                dry.open("/Admin/FieldType/new", true);
            };

            /*批量删除*/
            f.gDelete = function(object, checkStatus)
            {
                console.log(object);
                console.log(checkStatus);
            };

            /*即时编辑*/
            f.immediatelyEdit = function(object)
            {
                console.log(object);
            };

            /*表格渲染结束*/
            f.done = function(response, currentPage, count)
            {
                dry.mergeRequest();
                console.log(response);
                console.log(currentPage);
                console.log(count);
            };

            /*查看按钮*/
            f.show = function(object, id)
            {
                window.location.href = "/Admin/FieldType/show?id=" + id;
            };

            /*编辑按钮*/
            f.edit = function(object, id)
            {
                dry.open("/Admin/FieldType/edit?id=" + id, true);
            };

            dry.cardRightTopButton(f);

            dry.list("/Api/FieldType/index", getIndexColumn(), 10, f);
        });
    </script>
{% endblock %}
